package com.elvt.server.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.elvt.server.pojo.Employee;
import com.elvt.server.pojo.Salary;
import com.elvt.server.service.IEmployeeService;
import com.elvt.server.service.ISalaryService;
import com.elvt.server.utils.RespPageUtil;
import com.elvt.server.utils.RespSult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 作者： elvt
 * @Data 时间：2022/6/1
 * @packageName 包路径： ybg_back_end
 * @Desciption 说明： 员工账套
 */
@RestController
@RequestMapping("/salary/sobcfg")
public class SalarySobCfgController {
    @Autowired
    private ISalaryService salaryService;
    @Autowired
    private IEmployeeService employeeService;
    @ApiOperation(value = "获取所有工账套")
    @GetMapping("/salaries")
    public List<Salary> findSalaries(){
        return salaryService.list();

    }
    @ApiOperation(value = "获取所有的员工账套")
    @GetMapping
    public RespPageUtil getEmployeeSalary(@RequestParam(defaultValue ="1" ) Integer currentPage, @RequestParam(defaultValue = "10") Integer size){

        return employeeService. getEmployeeSalary(currentPage,size);

    }
    @ApiOperation(value = "更新员工账套")
    @PutMapping
    public RespSult updateEmployeeSalary(Integer eid ,Integer sid){
        boolean b = employeeService.update(new UpdateWrapper<Employee>().set("salaryId", sid).eq("id", eid));
        if (b){
            return RespSult.success("更新成功");

        }
        return RespSult.error("更新失败");

    }
}
